
#! /bin/bash

CURRENT_PWD=$(cd "$(dirname "$0")";pwd)

CURRENT_ARCH=$(dpkg --print-architecture)

PACKAGE_NAME="org.lxde.lxtask"
PACKAGE_VERSION="0.1.10"

# sudo apt-get update

# aclocal: not found
sudo apt-get install automake -y
# gtk+-2.0 not found
sudo apt-get install libgtk2.0-dev -y

cd ..

# fixed automake version mismatch
autoreconf

chmod +x configure

./configure --prefix=$CURRENT_PWD/debian/opt/apps/$PACKAGE_NAME/files

make -j8

make install

sed -i "/^Architecture:/cArchitecture: ${CURRENT_ARCH}" $CURRENT_PWD/debian/DEBIAN/control

cd $CURRENT_PWD

# mkdir -p $CURRENT_PWD/debian/opt/apps/$PACKAGE_NAME/files/bin
# cp ../src/lxterminal $CURRENT_PWD/debian/opt/apps/$PACKAGE_NAME/files/bin

# cp -rf $CURRENT_PWD/debian/opt/apps/$PACKAGE_NAME/files/share/applications/lxterminal.desktop $CURRENT_PWD/debian/opt/apps/$PACKAGE_NAME/entries/applications/$PACKAGE_NAME.desktop

# cp -rf $CURRENT_PWD/debian/opt/apps/$PACKAGE_NAME/files/share/icons $CURRENT_PWD/debian/opt/apps/$PACKAGE_NAME/entries

cp -rf $CURRENT_PWD/debian/opt/apps/$PACKAGE_NAME/files/share/locale $CURRENT_PWD/debian/opt/apps/$PACKAGE_NAME/entries

# Depends: libc6 (>= 2.27), libevent-2.1-7 (>= 2.1.8-stable), libtinfo6 (>= 6)
# dpkg-shlibdeps -O lxtask > shlibs.txt

# uos root-owner-group
dpkg-deb --root-owner-group  -b debian "${PACKAGE_NAME}_${PACKAGE_VERSION}_${CURRENT_ARCH}.deb"
